import {ref} from 'vue'
import {request} from '@pkg/request/src'

export function useDataSource(props?, initOptions?) {
  let chartData: any = ref([]);

  /**
   *查询数据
   */
  function queryData(config) {
    let {url, params} = config;
    request.get(
        {
          url: url,
          params: params,
        },
        {errorMessageMode: 'none', successMessageMode: 'none'},
    ).then((res) => {
      chartData.value = res;
      initOptions(chartData.value);
    });
  }

  return {
    queryData
  }
}
